#include<bits/stdc++.h>
using namespace std;
int T,n,a[10010],b[10010],ans;
void dfs(int x)
{
    if(x==n+1)
    {
        int u=0;
        for(int i=2;i<=n;i++)
        {
            for(int j=i-1;j>=1;j--)
            {
                if(b[i]==b[j]&&a[i]==a[j]) u+=a[i];
            }
        }
        ans=max(ans,u);
        return ;
    }
    dfs(x+1);
    b[x]=1;
    dfs(x+1);
}
int main()
{
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>T;
    while(T--)
    {
        ans=-1;
        cin>>n;
        for(int i=1;i<=n;i++)
            cin>>a[i];
            dfs(1);
        cout<<ans<<endl;
    }

    return 0;
}
